package pen_exam.jingdong2023_11_11;

import java.util.Scanner;

public class Class01_Mofa {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long[] read = new long[(int)n];
        for (int i = 0; i < n; i++) {
            read[i] = sc.nextLong();
        }
        long[][] blue = new long[(int)n][2];
        for (int i = 0; i < n; i++) {
            blue[i][0] = sc.nextLong() - 1;
            blue[i][1] = sc.nextLong() - 1;
        }

        long[] price = new long[(int) n];
        for (int i = 0; i < n; i++) {
            price[i] = Math.min(read[i],read[(int) blue[i][0]] + read[(int) blue[i][1]]);
        }
        long ans = 0;
        for(long x : price){
            ans += x;
        }
        System.out.println(ans);
    }
}
